/****************************************************************************/
/*                                                                          */
/* This file contains the interface functions                               */
/* you should use for the wet ex 2                                          */
/*                                                                          */ 
/****************************************************************************/

/****************************************************************************/
/*                                                                          */ 
/* File Name : library2.h                                                   */
/*                                                                          */ 
/****************************************************************************/

#ifndef _234218_WET2_
#define _234218_WET2_

#include "rational.h"

using namespace rational;

/* Return Values
 * ----------------------------------- */
typedef enum {
	SUCCESS = 0,
	FAILURE = -1,
	ALLOCATION_ERROR = -2,
	INVALID_INPUT = -3

} StatusType;


/* Required Interface for the Data Structure
 * -----------------------------------------*/


/* Description:   Initializes an empty sensor system.
 * Input:         None.
 * Output:        None.
 * Return Values: A pointer to a new instance of the data structure - as a void* pointer.
 */
void*       Init();


/* Description:   Add a new sensor to the system
 * Input:         DS - A pointer to the data structure.
 *				  id - the ID of the new sensor
 *                latitude - The latitude of the new sensor.
 *                temp - The temperature measured by the new sensor
 * Output:        None.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, id<0, latitude<0,  or temp < 0.
 *                FAILURE - If the sensor already exists in the system or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  AddSensor(void* DS, int id, Rational latitude, Rational temp);


/* Description:   Remove a sensor from the system.
 * Input:         DS - A pointer to the data structure.
 *                id - the id of the sensor.
 * Output:        None.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, id<0.
 *                FAILURE - If the requested sensor does not exists or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  RemoveSensor(void* DS, int);


/* Description:   Change the temperature measured in a sensor
 * Input:         DS - A pointer to the data structure.
 * 				  id - the ID of the requested sensor.
 * 				  temp - the new measured temperature
 * Output:        company - None
 * Return Values: INVALID_INPUT - If DS==NULL or id <0 or temp<0.
 *                FAILURE - In case a sensor with the requested id does not exists or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  ChangeSensorTemp(void* DS, int id, Rational temp);


/* Description:   Returns the temperature measured at a sensor
 * Input:         DS - A pointer to the data structure.
 *                id - the ID of the requested sensor
 * Output:        temp - the measured temperature at the requested sensor
 * Return Values: INVALID_INPUT - If DS==NULL, id<0 or temp==NULL.
 *                FAILURE - n case a sensor with the requested id does not exists or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  GetSensorTemp(void* DS, int id, Rational* temp);


/* Description:   Returns the average temperature measured between latitude1 and latitdue2
 * Input:         DS - A pointer to the data structure.
 * 				  latitude1 - the lowest latitude to consider in the average.
 * 				  latitude2 - the highest latitude to consider in the average.
 * Output:        temp - the average temperature.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, latitude1<0 or latitude2<0  or latitude2>latitude1 or temp==NULL.
 *                FAILURE - In case there are no sensors between latitude1 and latitdue2 or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  AverageTemp(void* DS, Rational latitude1, Rational latitude2, Rational* temp);


/* Description:   Returns the max temperature measured between latitude1 and latitdue2
 * Input:         DS - A pointer to the data structure.
 * 				  latitude1 - the lowest latitude to consider in the average.
 * 				  latitude2 - the highest latitude to consider in the average.
 * Output:        temp - the average temperature.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, latitude1<0 or latitude2<0  or latitude2>latitude1 or temp==NULL.
 *                FAILURE - In case there are no sensors between latitude1 and latitdue2 or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  MaxTemp(void* DS, Rational latitude1, Rational latitude2, Rational* temp);

/* Description:   Quits and deletes the database.
 *                DS should be set to NULL.
 *                      
 * Input:         DS - A pointer to the data structure.
 * Output:        None.
 * Return Values: None.
 */
void        Quit(void** DS);

#endif    /*_234218_WET1_ */ 
